
import { page } from './page/page.js'
class buss{
  constructor(app){
    console.log(app)
    this.ceshi = new page()
    this.app = app
    this.init(app,'onShow',this.e)
  }
  init(option,t,e){
    if (option[t]) {
      var o = option[t];
      option[t] = function (option) {
        e.call(this, option, t), o.call(this, option)
      }
    } else n[t] = function (n) {
      e.call(this, n, t)
    }
  }
  e(option){
    console.log(option)
    wx.login({
      success(res) {
        if (res.code) {
          // 发起网络请求
          wx.request({
            url: 'https://test.com/onLogin',
            data: {
              code: res.code
            }
          })
        } else {
          console.log('登录失败！' + res.errMsg)
        }
      }
    })
  }
}


let qy = function(){
  return function(o){
      ! function(){
        let  o  = App,
             t = Page;
      App = function(t){
        new buss(t)
        o(t)
      }
    }()
  }()
}
module.exports = qy()